Skip to content

feat(boto3): Add SQS/SNS trace propagation - #8145

Open
pabloDeputter wants to merge 4 commits into
pablo/boto3-add-sns-extensionfrom
pablo/boto3-add-sqs/sns-propagation
Open

pabloDeputter wants to merge 4 commits into
pablo/boto3-add-sns-extensionfrom
pablo/boto3-add-sqs/sns-propagation

Conversation

@pabloDeputter

@pabloDeputter pabloDeputter commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

Propagates the trace through SQS and SNS messages, so the consumer can be linked back to the request that sent the message.

Send side (SendMessage, SendMessageBatch, Publish, PublishBatch):

  • Adds sentry-trace and baggage as String message attributes, on the message or on each batch entry.
  • Only when trace_propagation_targets match the endpoint.
  • Skips a message if the caller already set these attributes, if it would go over the 10-attribute limit, or if it would go over 256 KiB. AWS would reject the message otherwise.
  • Works on a copy of the params. The caller's dict isn't changed.

Receive side (ReceiveMessage):

  • Adds sentry-trace and baggage to MessageAttributeNames, so SQS returns them. Only when the span is recorded, and not when the caller already asks for All or .*.
  • Adds a span link to each distinct producer context in the received messages, with sentry.link.type: message_origin.
  • Reads the context from SQS message attributes, and from the JSON envelope of an SNS notification without raw message delivery.

Tests: injection and extraction for single and batch calls, the limits above, and a round-trip test: send a message, receive what was injected, and check that the link points at the send span.

Stacked on #8142 (SNS), which is stacked on #8137 (SQS).

Issues

  • resolves: PY-3008

via @dingsdax.

--

View Session [Sentry]

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Results 📊

✅ 58450 passed | ⏭️ 3018 skipped | Total: 61468 | Pass Rate: 95.09% | Execution Time: 161m 28s

📊 Comparison with Base Branch

Metric Change
Total Tests 📉 -83209
Passed Tests 📉 -78771
Failed Tests —
Skipped Tests 📉 -4438

All tests are passing successfully.

✅ Patch coverage is 94.19% (81 of 86 changed executable lines covered; target 80%).
Project statement coverage is 90.45% (up 0.10 percentage points from base (54710b7) to head (3d35077)).

Changed files with executable lines (6)
File Patch coverage Changed executable lines
sentry_sdk/integrations/boto3/_utils.py 90.63% 29/32 covered; missed: 90, 102, 103; partial branches: 89, 99, 101
sentry_sdk/integrations/boto3/_services/sqs.py 94.87% 37/39 covered; missed: 48, 49
sentry_sdk/consts.py 100.00% 2/2 covered
sentry_sdk/integrations/boto3/_client.py 100.00% 5/5 covered
sentry_sdk/integrations/boto3/_services/base.py 100.00% 4/4 covered
sentry_sdk/integrations/boto3/_services/sns.py 100.00% 4/4 covered
Coverage diff
@@            Coverage Diff             @@
##        master     #8145       +/-##
==========================================
+ Coverage    90.35%    90.45%    +0.10%
==========================================
  Files          203       199        -4
  Tracked lines     26931     21498     -5433
  Branches     10058      7468     -2590
==========================================
- Hits         24331     19444     -4887
+ Misses        2600      2054      -546
+ Partials      1517      1236      -281

Generated by Coverage Action

sentry-junior Bot and others added 2 commits November 9, 2026 07:05
Co-Authored-By: Johannes Daxböck <114897+dingsdax@users.noreply.github.com>

# Conflicts:
#	sentry_sdk/integrations/boto3/_services/sqs.py
Send a message, receive what was injected, and check that the receive
span links to the send span. Covers SQS and an SNS notification
delivered to SQS without raw message delivery.

Co-Authored-By: johdax <114897+dingsdax@users.noreply.github.com>
@sentry-junior
sentry-junior Bot marked this pull request as ready for review November 9, 2026 12:05
@sentry-junior
sentry-junior Bot requested a review from a team as a code owner November 9, 2026 12:05
@linear-code

linear-code Bot commented Nov 9, 2026

Copy link
Copy Markdown

PY-3008

…/sns-propagation

Co-Authored-By: Johannes Daxböck <114897+dingsdax@users.noreply.github.com>

# Conflicts:
#	sentry_sdk/integrations/boto3/_services/sns.py
#	sentry_sdk/integrations/boto3/_services/sqs.py
#	sentry_sdk/integrations/boto3/_utils.py

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant